package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FishMan;
import com.ruoyi.system.service.IFishManService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 鱼苗管理Controller
 * 
 * @author kinVincent22
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/system/fish_manage")
public class FishManController extends BaseController
{
    @Autowired
    private IFishManService fishManService;

    /**
     * 查询鱼苗管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(FishMan fishMan)
    {
        startPage();
        List<FishMan> list = fishManService.selectFishManList(fishMan);
        return getDataTable(list);
    }

    /**
     * 导出鱼苗管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:export')")
    @Log(title = "鱼苗管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FishMan fishMan)
    {
        List<FishMan> list = fishManService.selectFishManList(fishMan);
        ExcelUtil<FishMan> util = new ExcelUtil<FishMan>(FishMan.class);
        util.exportExcel(response, list, "鱼苗管理数据");
    }

    /**
     * 获取鱼苗管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:query')")
    @GetMapping(value = "/{fishId}")
    public AjaxResult getInfo(@PathVariable("fishId") Long fishId)
    {
        return success(fishManService.selectFishManByFishId(fishId));
    }

    /**
     * 新增鱼苗管理
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:add')")
    @Log(title = "鱼苗管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FishMan fishMan)
    {
        return toAjax(fishManService.insertFishMan(fishMan));
    }

    /**
     * 修改鱼苗管理
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:edit')")
    @Log(title = "鱼苗管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FishMan fishMan)
    {
        return toAjax(fishManService.updateFishMan(fishMan));
    }

    /**
     * 删除鱼苗管理
     */
    @PreAuthorize("@ss.hasPermi('system:fish_manage:remove')")
    @Log(title = "鱼苗管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fishIds}")
    public AjaxResult remove(@PathVariable Long[] fishIds)
    {
        return toAjax(fishManService.deleteFishManByFishIds(fishIds));
    }
}
